/**
 * @author        Nicolas Bottarini <nicolasbottarini@gmail.com>, 404 <http://www.proyecto404.com>
 * @version       $Rev: 3 $
 * @lastrevision  $Date: 2011-09-12 16:45:37 +0000 (Mon, 12 Sep 2011) $	 
 */
package com.proyecto404.core.collections {
	import com.proyecto404.core.BaseObject;
	import com.proyecto404.core.Check;
	import com.proyecto404.core.exception.InvalidOperationException;
	import com.proyecto404.core.exception.NotImplementedException;
	
	public class ReadOnlyQueue extends BaseObject implements IQueue {
		private var _queue:IQueue;
		
		public function ReadOnlyQueue(queue:IQueue) {
			_queue = queue;
		}
		
		public function withValue(value:*):IQueue {
			throw new InvalidOperationException("Cannot change readonly queue");
		}
		
		public function withValuesFrom(values:*):IQueue {
			throw new InvalidOperationException("Cannot change readonly queue");
		}
		
		public function count():int {
			return _queue.count();
		}
		
		public function isEmpty():Boolean {
			return _queue.isEmpty();
		}
		
		public function contains(value:*):Boolean {
			return _queue.contains(value);
		}
		
		public function clear():void {
			throw new InvalidOperationException("Cannot change readonly queue");
		}
		
		public function toList():IList {
			return _queue.toList();
		}
		
		public function toArray():Array {
			return _queue.toArray();
		}
		
		public function toSet():ISet {
			return _queue.toSet();
		}
		
		public function enqueue(value:*):void {
			throw new InvalidOperationException("Cannot change readonly queue");
		}
		
		public function peek():* {
			return _queue.peek();
		}

		public function poll():* {
			throw new InvalidOperationException("Cannot change readonly queue");
		}

		public function add(value:*):void {
			throw new InvalidOperationException("Cannot change readonly queue");
		}
		
		public function remove(value:*):void {
			throw new InvalidOperationException("Cannot change readonly queue");
		}
		
		public function removeFromArray(array:Array):void {
			throw new InvalidOperationException("Cannot change readonly queue");
		}
		
		public function removeFromCollection(collection:ICollection):void {
			throw new InvalidOperationException("Cannot change readonly queue");
		}

		public function addFromArray(array:Array):void {
			throw new InvalidOperationException("Cannot change readonly queue");
		}
		
		public function addFromCollection(collection:ICollection):void {
			throw new InvalidOperationException("Cannot change readonly queue");
		}
		
		public function asReadOnly():ICollection {
			return this;
		}
		
		public function getIterator():IIterator {
			return _queue.getIterator();
		}
		
		public function implode(separator:String = ","):String {
			return _queue.implode(separator);
		}
		
		public override function toString():String {
			return "ReadOnlyQueue{" + implode() + "}";
		}
		
		public override function equals(value:*):Boolean {
			if(!(value is ReadOnlyQueue)) return false;
			return _queue.equals(ReadOnlyQueue(value)._queue);
		}
		
		public function collect(criteria:Function):ICollection {
			return _queue.collect(criteria);
		}
		
		public function forEach(callback:Function):void {
			_queue.forEach(callback);
		}
		
		public function map(convert:Function):ICollection {
			return _queue.map(convert);
		}
		
		public function all(criteria:Function):Boolean {
			return _queue.all(criteria);
		}
		
		public function any(criteria:Function):Boolean {
			return _queue.any(criteria);
		}
	}
}